<template>
  <div class="video">
    <div
      class="video-item"
      v-for="(item, index) in video"
      :key="index"
      @click="send(item.vid)"
    >
      <div class="img">
        <img width="159px" height="90px" :src="item.coverUrl" alt="" />
        <div class="play-count">
          <i></i>
          <span>
            {{ item.playTime | count }}
          </span>
        </div>
        <div class="play-time">{{ item.durationms | time }}</div>
      </div>
      <div class="text">
        <div class="myicon">
          <div v-if="item.vid.length <= 8" class="mvicon"></div>
          <span>{{ item.title }}</span>
        </div>
        <p style="color: #0c73c2; font-size: 12px">林俊杰</p>
      </div>
    </div>
  </div>
</template>
<script >
import moment from 'moment'

export default {
  props: ['video'],
  filters: {
    count(v) {
      return v > 100000 ? (v / 10000).toFixed(0) + '万' : v + '次'
    },
    time(v) {
      return moment(v).format('mm:ss')
    },
  },
  methods:{
      send(id){
        if(id.length <= 8){
       this.$router.push( '/mv/'+ id )
        }else{
       this.$router.push( '/video/'+ id )
        }
      }
  }

}
</script>
<style scoped lang="less">
.video {
  flex-wrap: wrap;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
}
.video-item {
  display: flex;
  width: 20%;
  flex-direction: column;
  padding-top: 20px;
  .img {
    width: 159px;
    position: relative;
  }

  .play-count {
    height: 20px;
    position: absolute;
    top: 0;
    right: 0;
    color: white;
    font-size: 14px;
    width: 55%;
    background: url(../assets/images/mask.png);
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-right: 5px;
    span {
      font-size: 12px;
    }
    i {
      width: 15px;
      display: block;
      height: 10px;
      background: url(../assets/images/icon2.png) -60px -310px;
      margin-right: 5px;
    }
  }
  .play-time {
    font-size: 12px;
    position: absolute;
    bottom: 5px;
    left: 5px;
    color: white;
  }
}
// mv 小图标
.mvicon {
  margin: 0 5px 0 0;
  width: 26px;
  height: 16px;
  background: url(../assets/images/icon2.png) -270px -480px;
}
.myicon {
  margin-top: 10px;
  display: flex;
  padding-right: 20px;
  overflow: hidden;
  span {
    width: 128px;
    font-size: 14px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
// 作者信息
.text {
  display: flex;
  flex-direction: column;
  width: 100%;
}
</style>